<template>
  <div class="Playing">
    <Playing :chapter="chapter" :items="items" :cur_day="items.cur_day" v-if="chapter"></Playing>
    <!--<Modify v-show="true"></Modify>-->
  </div>
</template>

<script>
  import Playing from '../../components/NewPlayings/index'

  export default {
    name: 'index',
    data: function () {
      return {
        data: this.$route.query,
        chapter: null,
        items: {}
      }
    },
    mounted: function () {
      if (this.data.chapter_id) {
        this.Chapter()
      } else {
        this.update()
      }
    },
    methods: {
      update: function () {
        // 设置platform_book_id
        this.data.platform_book_id = window.sessionStorage.getItem('ten_platform_book_id')?window.sessionStorage.getItem('ten_platform_book_id'):this.$route.query.platform_book_id
        this.$axios.chapter_read(this.data).then(res => {
          this.chapter = res.data.qing_data.chapter
          this.items = res.data.qing_data
          sessionStorage.setItem('handout', this.$Mate.qingReadTextRetuen(this.chapter.chapter_handout_text))
        })
      },
      Chapter: function () {
        // 设置platform_book_id
        this.data.platform_book_id = window.sessionStorage.getItem('ten_platform_book_id')
        this.$axios.chapter_detail(this.data).then(res => {
          this.chapter = res.data.qing_data.chapter
          this.items = res.data.qing_data
          sessionStorage.setItem('handout', this.$Mate.qingReadTextRetuen(this.chapter.chapter_handout_text))
        })
      }
    },
    components: {Playing}
  }
</script>

<style scoped>
  @import "../../assets/css/views/Playing/index.css";
</style>
